import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Res } from '../../modal/Res';

/*
  Generated class for the ApiProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
*/
@Injectable()
export class ApiProvider {

  public IPProt = 'http://192.168.0.28:8080';
  public API = '/FourInOneAppServer';
  public url = this.IPProt + this.API;

  constructor(public http: HttpClient) {
    console.log('Hello ApiProvider Provider');
  }

  // 通用的范型

  // _post<I,O>(url,parmas): Promise<O>{
  //   return new Promise((resolve, reject)=>{
  //     this.http.post(url,parmas).subscribe( res => {
  //       resolve(<O>res);
  //     })
  //   })
  // }

  post(url, parmas) {
    return this.http.post(this.url + url, parmas);
  }

}
